import request from '@/utils/request';

// 上传接口路径
export const uploadUrl = '/common/upload';

export function upload(data){
  return request({
    method: 'post',
    url: uploadUrl,
    data
  })
}

export function download(params){
  return request({
    method: 'get',
    url: '/common/download',
    headers: {
      'Content-Type': 'application/octet-stream;charset=utf-8'
    },
    responseType: 'blob',
    params
  })
}

export function fileDownload(url){
  return request({
    method: 'get',
    url
  })
}
// 大文件上传预检
export function bigFilePerpare(data){
  return request({
    url: '/multipart-upload/create',
    method: 'post',
    data
  })
}
// 切片文件上传
export function chunkUpload(url, data){
  return request({
    url,
    data,
    method: 'put'
  });
}
// 请求合并文件
export function mergeChunk(data){
  return request({
    url: '/multipart-upload/complete',
    method: 'post',
    data
  })
}